﻿using System;

namespace Web7.Ioc
{
    /// <summary>当在派生类中实现时，提供登记服务与特定的依赖管理容器.</summary>
    public interface IWeb7ContainerBuilder
    {
        /// <summary>
        /// 包含配置的Build上下文
        /// </summary>
        IBuilderContext Context { get; }

        /// <summary>
        /// Reset容器建立
        /// </summary>
        void Reset();

        /// <summary>指定容器，以建立依赖Map</summary>
        /// <returns>An <see cref="IWeb7ContainerBuilder"/> 依赖服务接口</returns>
        IWeb7DependencyResolver Build();

        /// <summary>
        /// 添加需求的依赖项到容器中，并指示它来注册它的依赖。
        /// </summary>
        /// <param name="demandBuilder">需求建立者.</param>
        /// <returns>.</returns>
        IWeb7ContainerBuilder AddDependencyDemandBuilder(IDependencyDemandBuilder demandBuilder);

        /// <summary>从程序集中添加依赖需求建设者 <typeparamref name="T"/>.</summary>
        /// <typeparam name="T">从该Typ分配的类型(继承or实现)。</typeparam>
        /// <returns>.</returns>
        IWeb7ContainerBuilder AddDemandsFromAssemblyOf<T>();

        /// <summary>从程序集中添加依赖需求建设者</summary>
        /// <param name="type">从该Typ分配的类型(继承or实现)。</param>
        /// <returns>.</returns>
        IWeb7ContainerBuilder AddDemandsFromAssemblyOf(Type type);

        IDependencyRegistrar<TContract> ForInstanceOfType<TContract>(TContract implementation) where TContract : class;
        IDependencyRegistrar<TContract> ForFactory<TContract>(Func<IResolutionContext, TContract> @delegate);
        IDependencyRegistrar<object> For(Type type);
        IDependencyRegistrar<T> For<T>();
    }
}
